package solution;

import java.util.HashMap;

/**
 * @Author 刘牌
 * @Date 2020/2/16 0016 16:46
 * @Version 1.0
 */

public class TwoNum {

    /**
     * 暴力法
     * @param nums
     * @param target
     * @return
     */
     int[] two(int[] nums, int target){
        for (int i = 0 ; i < nums.length ; i++){
            for (int j = i + 1 ; j < nums.length ; j++){
                if (nums[j] == target - nums[i]){
                    return new int[]{nums[i],nums[j]};
                }
            }
        }
        throw new RuntimeException("没有");
    }

    public static void main(String[] args) {
        int[] two = new TwoNum().two(new int[]{2, 7, 11, 15}, 9);
        System.out.println(two[0]);
    }
}
